import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    user: { id: '', name: '', username: '', img: '' },
    ylist: [],
    nlist: [],
  },
  getters: {},
  mutations: {
    GetItemList(state, itemlist) {
      let ylist = itemlist.y;
      let nlist = itemlist.n;
      state.ylist.splice(0, state.ylist.length);
      state.nlist.splice(0, state.nlist.length);
      for (let i = 0; i < ylist.length; i++) {
        state.ylist[i] = ylist[i];
      }
      for (let i = 0; i < nlist.length; i++) {
        state.nlist[i] = nlist[i];
      }
    },
    GetUser(state, user) {
      state.user.id = user.id;
      state.user.name = user.name;
      state.user.username = user.username;
      state.user.img = user.img;
    },
  },
  actions: {},
  modules: {},
});
